public class ArithmeticOp extends Operator {
	
	public ArithmeticOp(String newOp) {
		super(newOp);
	}
	
	@Override
	public boolean isArithmeticOp() { return true; }

	@Override
	public STO checkOperands(STO left, STO right) { 
		if (left.isError()) { 
			return left ;
		}
		if (right.isError()){
			return right;
		}
		STO sto = null;
		Type l_type = left.getType();
		Type r_type = right.getType();
		boolean l_numeric = l_type.isNumeric();
		boolean r_numeric = r_type.isNumeric();
		if(l_numeric && r_numeric) {
			if(left.isConst() && right.isConst()) {
				if(l_type.isFloat() || r_type.isFloat()) {
					sto = new ConstSTO("result", new FloatType());
				}
				else {
					sto = new ConstSTO("result", new IntType());
				}
			}
			else {
				if(l_type.isFloat() || r_type.isFloat()) {
					if(left.isVar()) {
						sto = new ExprSTO(left.getName(), new FloatType());
					}
					else {
						sto = new ExprSTO(right.getName(), new FloatType());
					}
				}
				else {
					if(!left.isConst()) {
						sto = new ExprSTO(left.getName(), new IntType());
					}
					else {
						sto = new ExprSTO(right.getName(), new IntType());
					}
				}
			}
		}
		else {
		 	sto = new ErrorSTO("error1n_Expr");
		}
		return sto;
	}
}
